<?php
	if (isset($_POST['PHPSESSID'])) {
		session_id($_POST['PHPSESSID']);
	}
#session_start();
require("base/ccdsBackend.inc.php");

class ccdsFrontend extends ccdsBackend {
	
	function loginstatus( &$callnext )
	{

		$objModuleManager = ccdsModuleManager::getInstance();
		$plugin = $objModuleManager->get( 'ccdsFrontendEdit2' );

		if ( !$plugin->check_login() && $_REQUEST['ccdsfun'] != 'loginUser'  && $_REQUEST['ccdsfun'] != 'UserRequestPass'  )
		{
			$callnext = array (false);
			$objResponse = new ccdsResponse();
			$objResponse->loadCommands( $plugin->logout() );
			return $objResponse;
		}
		$_SESSION['CMS']['preview'] = 1;

	}
	
	

	function run()
	{
		$xajax = ccdsXajax::getInstance();

		$xajax->register( XAJAX_PROCESSING_EVENT, XAJAX_PROCESSING_EVENT_BEFORE, array
		(
			$this,
			"loginstatus"
		));

		$xajax->processRequest();
		//$xajax->autoCompressJavaScript( $this->config->get( 'DOC_ROOT' ).$this->config->get( 'CMS_WEB_DIR' )."js/backend.js", true );
		//$xajax->autoCompressJavaScript( $this->config->get( 'DOC_ROOT' ).$this->config->get( 'CMS_WEB_DIR' )."js/comet.js", true );

		$xajax->autoCompressJavaScript( $this->config->get( 'LIBRARY_DIR' )."/xajax/xajax_plugins/response/TabManager/TabManager.js", true );

		$objModuleManager = ccdsModuleManager::getInstance();
		$plugin = $objModuleManager->get( 'ccdsFrontendEdit2' );

		$plugin->run();
	}	
	
	
}


$ccds = new ccdsFrontend();
$ccds->run();